package com.collection.provider.service;

import java.util.HashMap;
import java.util.List;

import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

import com.alibaba.dubbo.config.annotation.Service;
import com.collection.api.UBaseService;
import com.collection.api.entity.UBase;
import com.collection.api.entity.UBaseExample;
import com.collection.provider.biz.UBaseBiz;

@Service(version ="1.0.0")
public class UBaseServiceImpl implements UBaseService{
	@Autowired
	private UBaseBiz uBaseBiz;
	@Override
	public int deleteByPrimaryKey(Long id) {
		return 0;
	}

	@Override
	public int insert(UBase record) {
		return uBaseBiz.insert(record);
		}

	@Override
	public int insertSelective(UBase record) {
		return 0;
	}

	@Override
	public List<UBase> selectByExample(UBaseExample example) {
		return null;
	}

	@Override
	public UBase selectByPrimaryKey(Long id) {
		return null;
	}

	@Override
	public int updateByPrimaryKeySelective(UBase record) {
		return 0;
	}

	@Override
	public int updateByPrimaryKey(UBase record) {
		return 0;
	}


	@Override
	public List<Map<String, Object>> selectUbaseAll(String name, String idNo, String phone, String auditUserId,
			Integer id, Integer offset, Integer limit, String auditTime1, String auditTime2, String status,
			String realName) {
		Map<String, Object> map = new HashMap<String, Object>();
		if (StringUtils.isNoneBlank(name)) {
			map.put("name", name);
		}
		if (StringUtils.isNoneBlank(idNo)) {
			map.put("idNo", idNo);
		}
		if (StringUtils.isNoneBlank(phone)) {
			map.put("phone", phone);
		}
		if (StringUtils.isNoneBlank(auditTime1)) {
			map.put("auditTime1", auditTime1);
		}
		if (StringUtils.isNoneBlank(auditTime2)) {
			map.put("auditTime2", auditTime2);
		}
		if (auditUserId != null) {
			map.put("auditUserId", auditUserId);
		}
		if (null != offset && !"".equals(offset)) {
			map.put("offset", offset);
		}
		if (null != limit && !"".equals(limit)) {
			map.put("limit", limit);
		}
		if (null != status && !"".equals(status)) {
			map.put("status", status);
		}
		if (StringUtils.isNoneBlank(realName)) {
			map.put("realName", realName);
		}

		List<Map<String, Object>> selectUbaseAll = uBaseBiz.selectUbaseAll(map);
		return selectUbaseAll;
	}

	@Override
	public int selectUbaseCount(String name, String idNo, String phone, String auditUserId, String auditTime1,
									String auditTime2, String status, String realName ) {
		Map<String, Object> map = new HashMap<String, Object>();
		if (StringUtils.isNoneBlank(name)) {
			map.put("name", name);
		}
		if (StringUtils.isNoneBlank(idNo)) {
			map.put("idNo", idNo);
		}
		if (StringUtils.isNoneBlank(phone)) {
			map.put("phone", phone);
		}
		if (auditUserId != null) {
			map.put("auditUserId", auditUserId);
		}
		if (StringUtils.isNoneBlank(auditTime1)) {
			map.put("auditTime1", auditTime1);
		}
		if (StringUtils.isNoneBlank(auditTime2)) {
			map.put("auditTime2", auditTime2);
		}
		if (null != status && !"".equals(status)) {
			map.put("status", status);
		}
		if (StringUtils.isNoneBlank(realName)) {
			map.put("realName", realName);
		}
		return  uBaseBiz.selectUbaseCount(map);
	}

	@Override
	public List<Map<String, Object>> selectUbaseAllSH(String name, String idNo, String phone,  
			Integer id, Integer offset, Integer limit, String auditTime1, String auditTime2, String status,
			String realName,String type) {
		Map<String, Object> map = new HashMap<String, Object>();
		if (StringUtils.isNoneBlank(name)) {
			map.put("name", name);
		}
		if (StringUtils.isNoneBlank(idNo)) {
			map.put("idNo", idNo);
		}
		if (StringUtils.isNoneBlank(phone)) {
			map.put("phone", phone);
		}
		if (StringUtils.isNoneBlank(auditTime1)) {
			map.put("auditTime1", auditTime1);
		}
		if (StringUtils.isNoneBlank(auditTime2)) {
			map.put("auditTime2", auditTime2);
		}
		if (null != offset && !"".equals(offset)) {
			map.put("offset", offset);
		}
		if (null != limit && !"".equals(limit)) {
			map.put("limit", limit);
		}
		if (null != status && !"".equals(status)) {
			map.put("status", status);
		}
		if (StringUtils.isNoneBlank(realName)) {
			map.put("realName", realName);
		}
		if (StringUtils.isNoneBlank(type)) {
			map.put("type", type);
		}

		List<Map<String, Object>> selectUbaseAll = uBaseBiz.selectUbaseAllSH(map);
		return selectUbaseAll;
	}

	@Override
	public int selectUbaseCountSH(String name, String idNo, String phone , String auditTime1,
			String auditTime2, String status, String realName,String type) {
		Map<String, Object> map = new HashMap<String, Object>();
		if (StringUtils.isNoneBlank(name)) {
			map.put("name", name);
		}
		if (StringUtils.isNoneBlank(idNo)) {
			map.put("idNo", idNo);
		}
		if (StringUtils.isNoneBlank(phone)) {
			map.put("phone", phone);
		}
		if (StringUtils.isNoneBlank(auditTime1)) {
			map.put("auditTime1", auditTime1);
		}
		if (StringUtils.isNoneBlank(auditTime2)) {
			map.put("auditTime2", auditTime2);
		}
		if (null != status && !"".equals(status)) {
			map.put("status", status);
		}
		if (StringUtils.isNoneBlank(realName)) {
			map.put("realName", realName);
		}
		if (StringUtils.isNoneBlank(type)) {
			map.put("type", type);
		}
		return  uBaseBiz.selectUbaseCountSH(map);
	}

}
